home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
batch
/
sputls
/
demo1.bat
< prev
next >
Wrap
DOS Batch File
|
1991-01-08
|
16KB
|
462 lines
echo off
rem ------------------------------------------------------
rem batch file 1
rem
rem (C) speter software, January 1991.
rem ------------------------------------------------------
rem this batch file will:
rem 1 demonstrate the function of the batch utilities;
rem 2 show the documentation for the utilities;
rem 3 show demonstrations of the utilities.
rem ------------------------------------------------------
rem This section sets up the DOS environment variables used in this
rem batch file.
rem set (ANSI) text colour to white on blue
echo H
1H
hasmouse
if errorlevel 1 set _um=T
rem suppress text cursor if mouse is available:
if %_um%==T set _t=/t
rem chose which "more" command to use:
if %_um%==T set _m=mormouse /c
if not %_um%==T set _m=more
rem choose which prompt to use:
if %_um%==T set _p=/t press a button to continue
if not %_um%==T set _p=press any key to continue
rem --------------------------------------------------
rem page 0 (general intro)
rem --------------------------------------------------
copyrect demo-p0.scr 0 1 1
askmouse 51 23 52 23 Xx* 51 23 /m
if errorlevel 203 goto ok
if errorlevel 202 goto end
rem --------------------------------------------------
rem page 1 (provides short descriptions of utilities)
rem --------------------------------------------------
copyrect demo-p1.scr 0 1 1
copyrect 0 37 2 80 25 1 37 2
:in-p1
askmouse 26 3 36 22 q 26 11 %_t%
rem ---- mouse (or text cursor) entry
if errorlevel 122 goto end
if errorlevel 121 goto demos
if errorlevel 120 goto docs
if errorlevel 119 goto in-p1
if errorlevel 118 BoxText /s1 s 37 17 113 Removes TABs from an file, replacing!them with SPACEs, writes the result to!a file.
if errorlevel 117 BoxText /s1 s 37 16 113 Deletes a word (or series of) from a!file, the result is written to another!file.
if errorlevel 116 BoxText /s1 s 37 15 113 Deletes any characters within a spec. !column range, writes the result to!a file.
if errorlevel 115 BoxText /s1 s 37 14 113 Displays all (255) text attributes - !foreground, background colour &!blinking.
if errorlevel 114 BoxText /s1 s 37 13 113 Reports the length of the longest line!of a specified text file & the no.!of lines.
if errorlevel 113 BoxText /s1 s 37 12 113 Show the Disk Usage - total bytes used!in the spec. directory and sub-dirs.
if errorlevel 112 BoxText /s1 s 37 11 113 Simple decimal to binary (and Hex) !converter (numbers less than 65768).
if errorlevel 111 goto in-p1
if errorlevel 110 BoxText /s1 s 37 9 113 Similar to DOS "more" command, except !uses mouse-button press INSTEAD of a!keypress.
if errorlevel 109 BoxText /s1 s 37 8 113 Used in batch files to determine mouse!availability, sets the DOS errorlevel.
if errorlevel 108 BoxText /s1 s 37 7 113 Display a message using a specified !text attribute.
if errorlevel 107 BoxText /s1 s 37 6 113 Copy part (or all) of a text screen!to/from disk & other (nonvisible) text!screens.
if errorlevel 106 BoxText /s1 s 37 5 113 Wait for a mouse-button or key press;!optionally display a message before !waiting.
if errorlevel 105 BoxText /s1 s 37 4 113 Display a message inside a box using a!specified text attribute.!* * used here * *
if errorlevel 104 BoxText /s1 s 37 3 113 Display a box using a specified text !attribute, by default clears inside!the box.
if errorlevel 103 BoxText /s1 s 37 2 113 For selections in batch files, uses a !mouse, cursor keys &/or specified!characters.
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
copyrect 1 37 2 80 25 0 37 2
goto in-p1
rem --------------------------------------------------
rem page 2 (displays full documentation on utilities)
rem --------------------------------------------------
:docs
copyrect 0 1 1 80 25 1 1 1 (copy display page 0 to display page 1)
copyrect demo-p2.scr 2 1 1 (read 2nd page from file)
:in-p2
copyrect 2 1 1 80 25 0 1 1 (copy 2nd page to display page 0)
askmouse 26 3 34 20 q 26 11 %_t%
rem ---- mouse (or text cursor) entry
if errorlevel 120 goto P2return
if errorlevel 119 goto in-p2
if errorlevel 118 %_m% < striptab.doc
if errorlevel 117 %_m% < stripstr.doc
if errorlevel 116 %_m% < stripcol.doc
if errorlevel 115 %_m% < showattr.doc
if errorlevel 114 %_m% < linelen.doc
if errorlevel 113 %_m% < du.doc
if errorlevel 112 %_m% < binary.doc
if errorlevel 111 goto in-p2
if errorlevel 110 %_m% < mormouse.doc
if errorlevel 109 %_m% < hasmouse.doc
if errorlevel 108 %_m% < dtext.doc
if errorlevel 107 %_m% < copyrect.doc
if errorlevel 106 %_m% < butnpres.doc
if errorlevel 105 %_m% < boxtext.doc
if errorlevel 104 %_m% < box.doc
if errorlevel 103 %_m% < askmouse.doc
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p2
:P2return
copyrect 2 1 1 30 1 1 1 1 ( rewrite portion that gets cleared by "cls" )
copyrect 1 1 1 80 25 0 1 1 ( restore page 1 to display page 0 )
goto in-p1
rem --------------------------------------------------
rem page 3 (gives demonstrations of the utilities)
rem --------------------------------------------------
:demos
copyrect 0 1 1 80 25 1 1 1 (copy display page 0 to display page 1)
copyrect demo-p3.scr 3 1 1 (read 3rd page from file)
:in-p3
copyrect 3 1 1 80 25 0 1 1 (copy 3rd page to display page 0)
askmouse 26 3 34 20 q 26 11 %_t%
rem ---- mouse (or text cursor) entry
if errorlevel 120 goto P3return
if errorlevel 119 goto in-p3
if errorlevel 118 goto striptab
if errorlevel 117 goto stripstr
if errorlevel 116 goto stripcol
if errorlevel 115 goto showattr
if errorlevel 114 goto linelen
if errorlevel 113 goto du
if errorlevel 112 goto binary
if errorlevel 111 goto in-p3
if errorlevel 110 goto mormouse
if errorlevel 109 goto hasmouse
if errorlevel 108 goto dtext
if errorlevel 107 goto copyrect
if errorlevel 106 goto butnpres
if errorlevel 105 goto boxtext
if errorlevel 104 goto box
if errorlevel 103 goto askmouse
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
:P3return
copyrect 3 1 1 30 1 1 1 1 ( rewrite portion that gets cleared by "cls" )
copyrect 1 1 1 80 25 0 1 1 ( restore page 1 to display page 0 )
goto in-p1
rem --------------------------------------------------------
:striptab
cls
echo STRIP-TABs
echo
echo This demonstration will strip the tab characters from a file called TABS.TXT
echo (supplied with the utilities); the resulting text will then be displayed on
echo the screen.
echo
echo The command line used will be:
echo
echo STRIPTAB tabs.txt con
echo
butnpres %_p%
echo
STRIPTAB tabs.txt con
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:stripstr
cls
echo STRIP-STRING
echo
echo This demonstration will strip the string "efghijk" from a file called
echo LETTERS.TXT (supplied with the utilities); the resulting text will then be
echo displayed on the screen.
echo
echo LETTERS.TXT contains the string "abcdefghijklmnopqrstuvwxyz" 5 times.
echo
echo The command line used will be:
echo
echo STRIPSTR /sefghijk letters.txt con
echo
butnpres %_p%
echo
STRIPSTR /sefghijk letters.txt con
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:stripcol
cls
echo
echo STRIP COLUMN RANGE
echo
echo This demonstration will strip all the characters between column 10 and column
echo 20 from the file LETTERS.TXT (supplied with the utilities); the resulting text
echo will then be displayed on the screen.
echo
echo LETTERS.TXT contains the string "abcdefghijklmnopqrstuvwxyz" 5 times.
echo 10*---------*20
echo
echo the resulting text should be "abcdefghiuvwxyz" 5 times.
echo
echo The command line used will be:
echo
echo STRIPCOL 10 20 letters.txt con
echo
butnpres %_p%
echo
STRIPCOL 10 20 letters.txt con
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:showattr
cls
echo SHOW TEXT ATTRIBUTES
echo
echo This demonstration will simply execute the utility.
echo
echo The command line used will be:
echo
echo SHOWATTR
echo
butnpres %_p%
echo
SHOWATTR
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:linelen
cls
echo FILE (longest) LINE LENGTH
echo
echo This demonstration will execute the utility to determine the length of the
echo longest line in the demonstration batch file. The utility will also show the
echo line number of the longest line and the total number of lines in the file.
echo
echo The command line used will be:
echo
echo LINELEN DEMO1.BAT
echo
butnpres %_p%
echo
LINELEN DEMO1.BAT
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:du
cls
echo DISPLAY DISK USAGE FIGURES
echo
echo This demonstration will execute the utility to display the total disk space
echo taken up by the files in the current directory (and its sub-directories).
echo
echo The command line used will be:
echo
echo DU
echo
butnpres %_p%
echo
DU
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:binary
cls
echo DECIMAL TO BINARY CONVERTER
echo
echo This demonstration will simply execute the utility. When prompted, type in
echo a number between 0 to 65535, the utility will then display the binary (and
echo HEX) equivalent of the number.
echo
echo Enter the number 0 to exit the program.
echo
echo The command line used will be:
echo
echo BINARY
echo
butnpres %_p%
echo
BINARY
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:mormouse
cls
echo MORE MOUSE
echo
echo The more-mouse utility is used extensively throughout this demonstration.
echo Here it will be used to display the contents of the file "mormouse.doc".
echo
echo NOTE /c causes the screen to be cleared before the first page of the
echo file is displayed.
echo
echo The command used will be:
echo
dtext 3 11 23 "mormouse /c < mormouse.doc"
echo
echo
butnpres %_p%
mormouse /c < mormouse.doc
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:hasmouse
cls
echo HAS MOUSE ?
echo
echo This demonstration will execute the utility (which sets the DOS errorlevel),
echo the errorlevel is then used to branch to the appropriate message.
echo
echo An alternate way to use the errorlevel is to use it to set an DOS environment
echo variable, which can then be checked numerous times inside a batch file. This
echo is how this batch file uses HASMOUSE.
echo
echo The commands used will be:
echo
echo hasmouse
echo if errorlevel 1 goto mouseOK
echo if errorlevel 0 echo no mouse was found
echo goto h_m_end
echo :mouseOK
echo echo a mouse was found
echo :h_m_end
echo
butnpres %_p%
echo
echo
hasmouse
if errorlevel 1 goto mouseOK
if errorlevel 0 echo no mouse was found
goto h_m_end
:mouseOK
echo a mouse was found
:h_m_end
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:dtext
cls
echo DISPLAY A TEXT MESSAGE
echo
echo This demonstration will execute the utility to display a blinking message
echo "Hello All" on the display.
echo
echo The command line used will be:
echo
echo DTEXT 30 15 187 " Hello All "
echo
butnpres %_p%
echo
DTEXT 30 15 187 " Hello All "
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:copyrect
cls
echo COPY (rectangular) SCREEN AREA
echo
echo This demonstration will execute the utility to copy parts of this message
echo around the screen. This will, no doubt, make a fine mess all over the screen.
echo
echo The commands used will be:
echo
echo COPYRECT 0 1 3 10 9 0 40 10
echo COPYRECT 0 41 3 78 7 0 10 17
echo COPYRECT 0 3 8 10 12 0 60 10
echo COPYRECT 0 31 3 63 4 0 31 20
echo COPYRECT 0 21 4 78 4 0 10 25
echo
butnpres %_p%
COPYRECT 0 1 3 10 9 0 40 10
COPYRECT 0 41 3 78 7 0 10 17
COPYRECT 0 3 8 10 12 0 60 10
COPYRECT 0 31 3 63 4 0 31 20
COPYRECT 0 21 4 78 4 0 10 25
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:butnpres
cls
echo BUTTON-PRESS
echo
echo BUTTON-PRESS is functionally similar to the DOS "pause" command, it
echo (optionally) displays a message, then waits until a mouse-button or key is
echo pressed.
echo
echo This demonstration will execute the utility to display a blinking message
echo on the display, than wait for a keypress.
echo
echo BUTNPRES is being used in this batch file whenever you see the message:
echo %_p%
echo
echo The command line used will be:
echo
echo BUTNPRES 10 18 187 " Hello All Press a mouse-button or key when ready:"
echo
butnpres %_p%
echo
BUTNPRES 10 18 187 " Hello All Press a mouse-button or key when ready:"
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:boxtext
cls
echo DISPLAY A TEXT MESSAGE IN A BOX
echo
echo This demonstration will execute the utility to display a blinking message
echo "Hello All" on the display.
echo
echo The command line used will be:
echo
echo BOXTEXT /s1 s 30 15 187 " Hello All "
echo
butnpres %_p%
echo
BOXTEXT /s1 s 30 15 187 " Hello All "
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:box
cls
echo DISPLAY A BOX
echo
echo This demonstration will display a blinking box on the display!
echo
echo The command line used will be:
echo
echo BOX /s1 s 30 15 45 17 187
echo
butnpres %_p%
echo
BOX /s1 s 30 15 45 17 187
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:askmouse
cls
echo ASK MOUSE
echo
echo Ask Mouse is a utility that is meant to be functionally similar to the many
echo ASK utilities, except that this version allows for mouse (or text cursor)
echo input. The utility is intended for use in menus and similar occasions when
echo one option is to be chosen from amongst a range.
echo
echo Ask Mouse is used for all the menu selections in the batch file, and so,
echo needs no demonstration here :-)
echo
echo The commands used will be (the commands used at the end of each demo):
echo
echo BoxText /s1 s 73 23 103 OK - draw OK box
echo AskMouse 75 24 78 24 * 75 24 %%_t%% - button (or key)-press
BoxText /s1 s 73 23 103 OK
askmouse 75 24 78 24 * 75 24 %_t%
goto in-p3
rem --------------------------------------------------------
:end
set _um=
set _t=
echo
cls
:exit